package com.tool.btn;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.List;

import com.updateNew.MyIsif;
import org.come.Frame.*;
import org.come.bean.PathPoint;

import javax.swing.*;

import org.come.Jpanel.ContinuousRechargeGoodsJpanel;
import org.come.Jpanel.EveryDayOddsJpanel;
import org.come.Jpanel.EverydayRechargeGoodsJpanel;
import org.come.Jpanel.ImpactGradeGoodsJpanel;
import org.come.Jpanel.ImpactGradeJpanel;
import org.come.Jpanel.RechargeVIPGoodsJpanel;
import org.come.Jpanel.VipGoodsJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.socket.Agreement;
import org.come.Jpanel.GameJpanel;
import org.come.socket.SendMessageUntil;
import org.come.until.*;

import com.tool.tcpimg.UIUtils;

 

public class VipShopBtn extends MoBanBtn {
	private int formsid;
	private int caozuo;

	/** VIP反馈面板 */
	private VipGoodsJpanel vipGoodsJpanel;
	private RechargeVIPGoodsJpanel rechargeVIPGoodsJpanel;
    private String vicon;

	public VipShopBtn(String iconpath, int type, int caozuo) {
		super(iconpath, type);
		this.caozuo = caozuo;
	}
	public VipShopBtn(String iconpath, int type,int caozuo, String vicon) {
        super(iconpath, type);
        this.vicon = vicon;
        this.caozuo = caozuo;
    }
	boolean is;

	public VipShopBtn(String iconpath, int type, int caozuo, boolean is) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.is = is;
	}

	/** VIP反馈面板1 */
	public VipShopBtn(String iconpath, int type, int caozuo, VipGoodsJpanel vipGoodsJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.vipGoodsJpanel = vipGoodsJpanel;
	}
	
	/** VIP反馈面板1 */
	public VipShopBtn(String iconpath, int type, int caozuo, RechargeVIPGoodsJpanel rechargeVIPGoodsJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.rechargeVIPGoodsJpanel = rechargeVIPGoodsJpanel;
	}

	/** 连续充值面板 */
	private ContinuousRechargeGoodsJpanel continuousRechargeGoodsJpanel;

	/** 连续充值面板2 */
	public VipShopBtn(String iconpath, int type, int caozuo, ContinuousRechargeGoodsJpanel continuousRechargeGoodsJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.continuousRechargeGoodsJpanel = continuousRechargeGoodsJpanel;
	}

	/** 每日充值面板 */
	private EverydayRechargeGoodsJpanel everydayRechargeGoodsJpanel;

	public VipShopBtn(String iconpath, int type, int caozuo, EverydayRechargeGoodsJpanel everydayRechargeGoodsJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.everydayRechargeGoodsJpanel = everydayRechargeGoodsJpanel;
	}

	/** 每日特惠面板 */
	private EveryDayOddsJpanel everyDayOddsJpanel;

	public VipShopBtn(String iconpath, int type, int caozuo, String text, EveryDayOddsJpanel everyDayOddsJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		setText(text);
		setForeground(Color.white);
		setFont(UIUtils.TEXT_FONT);
		setVerticalTextPosition(SwingConstants.CENTER);
		setHorizontalTextPosition(SwingConstants.CENTER);
		this.everyDayOddsJpanel = everyDayOddsJpanel;
	}

	/** 冲级主面板5-7 */
	private ImpactGradeJpanel impactGradeJpanel;

	public VipShopBtn(String iconpath, int type, int caozuo, ImpactGradeJpanel impactGradeJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.impactGradeJpanel = impactGradeJpanel;
	}

	/** 冲级领取面板8 */
	private ImpactGradeGoodsJpanel impactGradeGoodsJpanel;

	/** 冲级领取面板8 */
	public VipShopBtn(String iconpath, int type, int caozuo, ImpactGradeGoodsJpanel impactGradeGoodsJpanel) {
		super(iconpath, type);
		this.caozuo = caozuo;
		this.impactGradeGoodsJpanel = impactGradeGoodsJpanel;
	}






	@Override
	public void chooseyes() {
		// TODO Auto-generated method stub

	}

	@Override
	public void chooseno() {
		// TODO Auto-generated method stub

	}

	@Override
	public void nochoose(MouseEvent e) {
		if (caozuo == 1) {
			vipGoodsJpanel.exchangeGoods();
		} else if (caozuo == 2) {

			continuousRechargeGoodsJpanel.exchangeGoods();
		} else if (caozuo == 3) {
			everydayRechargeGoodsJpanel.exchangeGoods();
		} else if (caozuo == 4) {
			if (GoodsListFromServerUntil.Surplussum("-1", "-1", 1) < 1) {
				ZhuFrame.getZhuJpanel().addPrompt2("你的背包不够");
				return;
			}
			everyDayOddsJpanel.exchangeGoods();
		} else if (caozuo >= 5 && caozuo <= 7) {
			impactGradeJpanel.changeMenuBtn(caozuo - 4);
		} else if (caozuo == 9 || caozuo == 10 || caozuo == 12) {
			impactGradeJpanel.changeMenuBtn(caozuo - 5);
		} else if (caozuo == 8) {
			impactGradeGoodsJpanel.exchangeGoods();
		} else if (caozuo == 50) {
			ImpactGradeJframe.getImpactGradeJframe().getImpactGradeJpanel().changeMenuBtn(-1);
		} else if (caozuo == 51) {
			ContinuousRechargeJframe.getContinuousRechargeJframe().getContinuousRechargeJpanel().getGoods();
		} else if (caozuo == 52) {
			EverydayRechargeJframe.getEverydayRechargeJframe().getEverydayRechargeJpanel().getGoods();
		} else if (caozuo == 53) {
			EveryDayOddsJframe.getEveryDayOddsJframe().getEveryDayOddsJpanel().getGoods();
		} else if (caozuo == 54) {
			changeVie();
		}else if (caozuo == 56) {
			caidan();
		}else if(caozuo == 55){
            if(vicon==null) {
                return;
            }
            String sendmes = Agreement.getAgreement().viconAgreement(vicon);
            SendMessageUntil.toServer(sendmes);
        }else if(caozuo == 40) {
            huodong();
        }else  if(caozuo == 57){
        	rechargeVIPGoodsJpanel.exchangeGoods();
        }
//后添加开启音效
		Music.addyinxiao("开关窗口.mp3");

   }
	

	
	
	
	public void huodong() {
		if (FormsManagement.getInternalForm2(40) != null) {
			ActivityJframe.getActivityJframe();
		}
		FormsManagement.showForm(this.formsid);

	}

	public void changeVie() {
		if (ZhuFrame.getZhuJpanel().getchongjiBtn() != null) {
			ZhuFrame.getZhuJpanel().getchongjiBtn().setVisible(is);
		}
		if (ZhuFrame.getZhuJpanel().getcontinuousBtn() != null) {
			ZhuFrame.getZhuJpanel().getcontinuousBtn().setVisible(is);
		}
		if (ZhuFrame.getZhuJpanel().getOddsBtn() != null) {
			ZhuFrame.getZhuJpanel().getOddsBtn().setVisible(is);
		}
		if (ZhuJpanel.getRechargeBtn() != null) {
			ZhuJpanel.getRechargeBtn().setVisible(is);
		}
//		if (ZhuFrame.getZhuJpanel().getShopingMenu() != null) {
//			ZhuFrame.getZhuJpanel().getShopingMenu().setVisible(is);
//		}
//		if (ZhuFrame.getZhuJpanel().getDrawMenu() != null) {
//			ZhuFrame.getZhuJpanel().getDrawMenu().setVisible(is);
//		}

		if (ZhuFrame.getZhuJpanel().getShowcaidan1() != null) {
			ZhuFrame.getZhuJpanel().getShowcaidan1().setVisible(is);

		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getPdBtn() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getPdBtn().setVisible(is);
		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getGuideBtn() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getGuideBtn().setVisible(is);
		}
//		ZhuFrame.getZhuJpanel();
//		if (ZhuJpanel.getCzlbBtn() != null) {
//			ZhuFrame.getZhuJpanel();
//			ZhuJpanel.getCzlbBtn().setVisible(is);
//		}
		
		
		List<VipShopBtn> btnListVicon = ZhuFrame.getZhuJpanel().getBtnListVicon();
        if(btnListVicon!=null){
            for (int i = 0; i < btnListVicon.size(); i++) {
                btnListVicon.get(i).setVisible(is);
            }
        }
		try {

			if("水墨UI".equals(MyIsif.getStyle())) {
				if (is) {
					ZhuFrame.getZhuJpanel().getShowVipBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajgb.png"));
				} else {
					ZhuFrame.getZhuJpanel().getShowVipBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajdk.png"));
				}
			}else {
				if (is) {
					ZhuFrame.getZhuJpanel().getShowVipBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajgbh.png"));
				} else {
					ZhuFrame.getZhuJpanel().getShowVipBtn().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajdkh.png"));
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		is = !is;
	}
	
	
	public void caidan() {//屏蔽左上角快捷操作几个按钮
//		PathPoint point=GameJpanel.getGameJpanel().mousepath();
		FormsManagement.HideForm(46);
		if (ZhuFrame.getZhuJpanel().getShowcaidan1() != null) {
			ZhuFrame.getZhuJpanel().getShowcaidan1().setVisible(is);
		
		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getPdBtn() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getPdBtn().setVisible(is);
		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getGuideBtn() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getGuideBtn().setVisible(is);
		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getKuaijieBtn() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getKuaijieBtn().setVisible(is);
		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getQianDaoMenu() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getQianDaoMenu().setVisible(is);
		}
//		ZhuFrame.getZhuJpanel();
//		if (ZhuJpanel.getCzlbBtn() != null) {
//			ZhuFrame.getZhuJpanel();
//			ZhuJpanel.getCzlbBtn().setVisible(is);
//		}
		ZhuFrame.getZhuJpanel();
		if (ZhuJpanel.getRechargeBtn() != null) {
			ZhuFrame.getZhuJpanel();
			ZhuJpanel.getRechargeBtn().setVisible(is);
		}
		if (ZhuFrame.getZhuJpanel().getchongjiBtn() != null) {
			ZhuFrame.getZhuJpanel().getchongjiBtn().setVisible(is);
		}
		List<VipShopBtn> btnListCaidan = ZhuFrame.getZhuJpanel().getBtnListVicon();
        if(btnListCaidan!=null){
            for (int w = 0; w < btnListCaidan.size(); w++) {
            	btnListCaidan.get(w).setVisible(is);
            }
        }
		try {

			if("水墨UI".equals(MyIsif.getStyle())) {
				if (is) {
					ZhuFrame.getZhuJpanel().getcaidan().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajgb.png"));
				} else {
					ZhuFrame.getZhuJpanel().getcaidan().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajdk.png"));
				}
			}else {
				if (is) {
					ZhuFrame.getZhuJpanel().getcaidan().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajgbh.png"));
				} else {
					ZhuFrame.getZhuJpanel().getcaidan().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/sjajdkh.png"));
				}
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			
			e.printStackTrace();
		}
		is = !is;
	}

	@Override
	public void mouseEntered(final MouseEvent e) {
		if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE1)) {
			MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
		}
	}

	@Override
	public void mouseExited(final MouseEvent e) {
		if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE12)) {
			MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
		}
	}
//	 @Override
//     public void mouseEntered(MouseEvent e) {
//
//     }
//
//     @Override
//     public void mouseExited(MouseEvent e) {
//
//
//     }
	
	
    public boolean isIs() {
        return is;
    }
    public void setIs(boolean is) {
        this.is = is;
    }
    public String getVicon() {
        return vicon;
    }
    public void setVicon(String vicon) {
        this.vicon = vicon;
    }
	
	
}
